import React, { Component } from 'react'
import empty from "../../assets/images/empty.jpg";
import "./Cart.css"
export default class Cart extends Component {
    state={
        carts:[]
    }
    //获取本地缓存中对的购物车数据
    componentDidMount(){
        let carts_str = localStorage.getItem("carts");
        let carts = JSON.parse(carts_str || "[]");
        this.setState({
            carts
        })
    }
    render() {
        return (
            <div className="yg-cart">
                {
                    !!this.state.carts.length?"":<div className="yg-cart-empty">
                        <img src={empty} alt=""/>
                        <h3 className="empty_text">
                            <a href="#/category">去逛逛</a>
                        </h3>
                    </div>
                }
            </div>
        )
    }
}
